﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace DiagramDesigner
{
    public class DIContentTemplateSelector : DataTemplateSelector
    {
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            PointCollection pointLine = item as PointCollection;
            FrameworkElement element = container as FrameworkElement;

            if (element != null)
            {

                if (pointLine != null)
                {
                    return element.FindResource("PolyLineTemplate") as DataTemplate;
                }
                else
                {
                    if (item is LineModel)
                        return element.FindResource("LineModelTemplate") as DataTemplate;
                    else
                    return null;
                }
            }

            return null;
        }
    }
}